define([ "PDUtilDir/grid", "PDUtilDir/searchBlock" ], function(Grid,
		SearchBlock) {

	function init(cache, addObj, updateObj, delObj, searchObj) {
		SearchBlock.init('searchBlockId');

		// 初始化
		return Grid({
			id : "TicketGirdDivId",
			pageSize : 10,
			index : true,
			multi : true,
			pagination : true,
			cache : false,
			layout : [ {
				name : "所属景区",
				field : "spotName",
				width : "10%",
				click : function(e) {
					updateObj.run(e.data.row);
				}
			}/*, {
				name : "门票代码",
				field : "code",
				sort : true,
				click : function(e) {
					updateObj.run(e.data.row);
				}
			}*/, {
				name : "所属景区",
				field : "spotName",
				width : "10%"
			}, {
                name : "成本价格",
                field : "price"
            }, {
                name : "外卖价格",
                field : "salePrice"
            }, {
				name : "数量",
				field : "number",
				sort : true
			}, {
				name : "类型",
				field : "type",
				width : "10%",
				format : function(e) {
//					var type = e.row.type;
//					if (type === "D_SPOT_TICKET_TYPE_ADULT") {
//						return "成人票";
//					} else if (type === "D_SPOT_TICKET_TYPE_CHILDREN")
//						return "儿童票"
					return cache.typeMap.get(e.row.type);
				}
			} ],
			toolbar : [ {
				name : "添加",
				icon : "fa fa-plus-circle",
				callback : function(event) {
					addObj.run();
				}
			}, {
				name : "删除",
				icon : "fa fa-search",
				callback : function(event) {
					delObj.run();
				}
			}, {
				name : "查询",
				icon : "fa fa-search",
				callback : function(event) {
					searchObj.run();
				}
			} ],
			data : {
				type : "URL",
				value : getServer() + "/flea/hclv/spotTicket/selectByDeptId.htmls"
			}
		});
	}
	return {
		init : init
	}
});